<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Time</title>
</head>
<body>
    <div style="color: #B03060">
        <h4 style="margin-top: 8px">小地方已经营</h4>
        <p id="htmer_time" >
    </div>

    <script>
    /* 运行时间统计 */
    function secondToDate(second) {
        if (!second) {
            return 0;
        }
        var time = new Array(0, 0, 0, 0, 0);
        // 1年 =  60秒 * 60分 * 24时 * 265天
        if (second >= 365 * 24 * 3600) {
            time[0] = parseInt(second / (365 * 24 * 3600));
            second %= 365 * 24 * 3600;
        }
        // 1天
        if (second >= 24 * 3600) {
            time[1] = parseInt(second / (24 * 3600));
            second %= 24 * 3600;
        }
        // 1时
        if (second >= 3600) {
            time[2] = parseInt(second / 3600);
            second %= 3600;
        }
        // 1分
        if (second >= 60) {
            time[3] = parseInt(second / 60);
            second %= 60;
        }
        if (second > 0) {
            time[4] = second;
        }
        return time;
    }
    function setTime() {
        /*此处为网站的创建时间*/
        // 设置的时间超出获取时间后，会显示：0年0天0时0分0秒
        var create_time = Math.round(new Date(Date.UTC(2020, 12, 12, 12, 12, 12)).getTime() / 1000);
        var timestamp = Math.round((new Date().getTime() + 8 * 60 * 60 * 1000) / 1000);
        currentTime = secondToDate((timestamp - create_time));
        currentTimeHtml = currentTime[0] + '年' + currentTime[1] + '天'
            + currentTime[2] + '时' + currentTime[3] + '分' + currentTime[4]
            + '秒';
        document.getElementById("htmer_time").innerHTML = currentTimeHtml;
    }
    setInterval(setTime, 1000);
</script>
</body>
</html>